package components.utils
{
	import components.core.UIComponent;

	import flash.display.Sprite;

	public class UIUtil
	{
		public function UIUtil()
		{
		}

		/**
		 *根据界面路径获取某个元件
		 * @param component
		 * @param path 路径：使用包的方式命名	。main.login
		 * @return
		 *
		 */
		public static function getSpriteByPath(component:Sprite, path:String):Sprite
		{
			var p:Array=path.split(".");
			var sprite:Sprite;

			for (var i:int=0; i < p.length; i++)
			{
				var name:String=p[i] as String;

				if (!sprite)
					sprite=component.getChildByName(name) as Sprite;
				else
					sprite=sprite.getChildByName(name) as Sprite;

				if (!sprite)
					break;
			}

			return sprite;
		}
	}
}